import sys
from PyQt4 import QtCore, QtGui, uic
from lib.papyDB import papyDB , tableInfo
from lib import papyDBTable
papyDB = papyDB()


class projMaker(QtGui.QDialog):
    def __init__(self):
        QtGui.QDialog.__init__(self)
        self.ui = uic.loadUi(r'D:/WORK/kali/General/papyrus/py/ui/projectMaker.ui')
        self.ui.show()
        self.connect(self.ui.make_button, QtCore.SIGNAL("clicked()"), self.makProj)
        self.ui.cancel_button.clicked.connect(QtCore.QCoreApplication.instance().quit)
    
    
    
    def chkBlank(self):
        complete = False
        
        if len(self.ui.pName_lineEdt.text())!=0 and len(self.ui.pCode_lineEdt.text())!=0 and self.ui.pType_cmbBox.currentIndex()!=0 and self.ui.pStatus_cmbBox.currentIndex()!=0:
            complete = True
            print "comlete"
        else :
            print "X"    
            
        return complete
        
        
        
    def makProj(self):
        
        pName = self.ui.pName_lineEdt.text()
        pCode = self.ui.pCode_lineEdt.text()
        pType = self.ui.pType_cmbBox.currentText()
        pStatus = self.ui.pStatus_cmbBox.currentText()
#        print type(self.ui.pDesc_txtEdt.toPlainText())
        print type(pName)
#        pDesc = self.ui.pDesc_txtEdt.toPlainText()
        
        print pName, pCode, pType, pStatus#, pDesc
        
#        pDesc = 'test'
        
        chk = self.chkBlank()        
        if chk == True :
#            print "make"      
            query = 'insert into PROJECT values(' + pName + ', ' + pCode + ', ' + pType + ', ' + pStatus + ')'#', ' + pDesc + ')'
            print query


        
    def closeEvent( self , event ) :        
        papyDB.cr.close()

if __name__=="__main__":
    app = QtGui.QApplication(sys.argv)
    projMaker = projMaker()
    sys.exit(app.exec_())
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    